/**
 * File name:      ServiceException.java
 * Date:           2011-9-2
 * Description:    // 用于详细说明此程序文件完成的主要功
 *                 // 能与其他模块或函数的接口，输出值、
 *                 // 取值范围、含义及参数间的关系
 * Modify History:     Date             Programmer       Notes
 *                    ---------        ---------------  ---------
 *                    2011-9-2             何指剑                         Initial
 **********************************************************************
 */
package com.wy.framework.exceptions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.wy.framework.constants.RtnCodeConstant;

/**
 * Created on 2011-9-2
 * <p>
 * Title: [子系统统名]_[模块名]/p>
 * <p>
 * Description: [描述该类概要功能介绍]
 * </p>
 * 
 * @version 1.0
 */
public class BusinessException extends Exception {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static Logger logger = LoggerFactory.getLogger(BusinessException.class);
	
	private String rspCode;

	private String rspMsg;
	
	private String rspMemo;

	/**
	 * 推荐使用ServiceException(Exception e),保留原有异常信息
	 */
	@Deprecated
	public BusinessException() {
		super("系统异常:" + RtnCodeConstant.RTN_CODE_UNKNOW_ERROR + "," + "系统异常,请联系管理员!");
		setRspCode(RtnCodeConstant.RTN_CODE_UNKNOW_ERROR);
		setRspMsg("系统异常,请联系管理员!");
	}
	
	public BusinessException(Exception e) {
		super("系统异常:" + RtnCodeConstant.RTN_CODE_UNKNOW_ERROR + "," + "系统异常,请联系管理员!", e);
		setRspCode(RtnCodeConstant.RTN_CODE_UNKNOW_ERROR);
		setRspMsg("系统异常,请联系管理员!");
		logger.info("系统异常,请联系管理员!",e);
	}

	public BusinessException(String code, String msg) {
		super("系统异常:" + code + "," + msg);
		setRspCode(code);
		setRspMsg(msg);
	}
	
    public BusinessException(String code, String msg, String memo) {
		super("系统异常:" + code + "," + msg + "," + memo);
		setRspCode(code);
		setRspMsg(msg);
		setRspMemo(memo);
	}

	public BusinessException(String code) {
		super("系统异常:" + code);
		setRspCode(code);
	}

	public BusinessException(String code, String msg, Exception e) {
		super(e);
		setRspCode(code);
		setRspMsg(msg);
		logger.info(msg,e);
	}
	
	public BusinessException(String code, String msg, String memo, Exception e) {
		super(e);
		setRspCode(code);
		setRspMsg(msg);
		setRspMemo(memo);
		logger.info(msg,e);
	}

	public String getRspMemo() {
	    return rspMemo;
	}

	public void setRspMemo(String rspMemo) {
	    this.rspMemo = rspMemo;
	}

	public String getRspCode() {
		return rspCode;
	}

	public void setRspCode(String rspCode) {
		this.rspCode = rspCode;
	}

	public String getRspMsg() {
		return rspMsg;
	}

	public void setRspMsg(String rspMsg) {
		this.rspMsg = rspMsg;
	}

}
